<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      width: 300px;
      height: 40px;
      border: 1px solid pink;
      text-align: center;
      line-height: 40px;
    }
  </style>
</head>

<body>
  <div></div>

  <script>
const div = document.querySelector('div')
function getdaytime(){
  const date = new Date()
const year = date.getFullYear()
const month = date.getMonth()
const day = date.getDate()
let h = date.getHours()
h=h<10?'0'+h:h;
let m = date.getMinutes()
m=m<10?'0'+m:m;
let s = date.getSeconds()
s=s<10?'0'+s:s;
div.innerHTML=`now is ${year}nian${month}yue${day}ri${h}:${m}:${s}`
}
getdaytime()
setInterval(getdaytime,1000)

    // 实现电子时间效果，在div里显示 现在是2024年11月21日 10:12:07 格式的时间


  </script>
</body>

</html>